package com.booking.springrestful.controller;

import com.booking.springrestful.domain.Consultationroom;
import com.booking.springrestful.domain.Homepagetexts;
import com.booking.springrestful.resp.ResponseResult;
import com.booking.springrestful.service.HomepagetextsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@Slf4j
@RequestMapping("/homepage")
public class HomepageController {

    @Resource
    private HomepagetextsService homepagetextsService;

    @PostMapping("/saveText")
    private ResponseResult saveText(@RequestBody Homepagetexts homepagetexts){
        homepagetextsService.saveText(homepagetexts);
        return ResponseResult.success("新增成功");
    }

    //根据标题修改全部
    @PostMapping("/updateText")
    private ResponseResult updateText(@RequestBody Homepagetexts homepagetexts){
        homepagetextsService.updateText(homepagetexts);
        return ResponseResult.success("修改成功");
    }

    //获取全部首页数据
    @GetMapping("/getText")
    private ResponseResult<List<Homepagetexts>> getText(){
        List<Homepagetexts> homepagetexts= homepagetextsService.getText();
        return ResponseResult.success(homepagetexts);
    }

}
